<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>新试界管理平台</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
  <link rel="stylesheet" href="/css/bootstrap.min.css">
  <link rel="stylesheet" href="/css/font-awesome.min.css">
  <link rel="stylesheet" href="/css/AdminLTE.min.css">

  <link rel="stylesheet" href="/css/all-skins.min.css">
  <link rel="stylesheet" href="/css/main.css">

</head>
<body class="hold-transition login-page">
<div class="login-box" id="rrapp" v-cloak>
  <div class="login-logo">
    <b>新试界管理平台</b>
  </div>
  <!-- /.login-logo -->
  <div class="login-box-body">
      <p class="login-box-msg">管理员登录</p>
      <div v-if="error" class="alert alert-danger alert-dismissible">
        <h4 style="margin-bottom: 0px;"><i class="fa fa-exclamation-circle"></i> {{errorMsg}}</h4>
      </div>
      <div class="form-group has-feedback">
          <input type="text" class="form-control" v-model="form.username" placeholder="账号/手机号">
          <span class="glyphicon glyphicon-user form-control-feedback"></span>
      </div>
      <div class="form-group has-feedback">
          <input type="password" class="form-control" v-model="form.password" placeholder="密码">
          <span class="glyphicon glyphicon-lock form-control-feedback"></span>
      </div>
      <!--<div class="row">-->
        <!--<div class="col-xs-8">-->
          <!--<div class="checkbox icheck">-->
          <!--</div>-->
        <!--</div>-->
        <!--&lt;!&ndash; /.col &ndash;&gt;-->
        <!--<div class="col-xs-4">-->
        <!--</div>-->
        <!--&lt;!&ndash; /.col &ndash;&gt;-->
      <!--</div>-->
      <div class="row" style="padding-top: 0px;">
          <div class="col-xs-6"></div>
          <div class="col-xs-3">
              <button type="button" class="btn btn-primary btn-flat" @click="login">登录</button>
          </div>
          <div class="col-xs-3">
              <button type="button" class="btn btn-primary btn-flat" @click="register">注册</button>
          </div>
      </div>
    <!-- /.social-auth-links -->

  </div>
  <!-- /.login-box-body -->
</div>
<!-- /.login-box -->
<script src="libs/jquery.min.js"></script>
<script src="/plugins/layer/layer.js"></script>
<script src="/libs/vue.min.js"></script>
<script src="/libs/bootstrap.min.js"></script>
<script src="/libs/app.js"></script>
<script src="/plugins/jqgrid/jquery.jqGrid.min.js"></script>
<script src="/js/common.js"></script>
<script type="text/javascript">
    var vm = new Vue({
        el:'#rrapp',
        data:{
            form: {
                username: '',
                password: ''
            },
            error: false,
            errorMsg: '',
            src: ''
        },
        beforeCreate: function(){
            if(self != top){
                top.location.href = self.location.href;
            }
        },
		created: function(){
			
		},
        methods: {
            login: function () {
                $.ajax({
                    type: "POST",
                    contentType:"application/json",
                    url: baseURL + "/auth/signin",
                    data: JSON.stringify(vm.form),
                    success: function(r){
                        if(r.code == 0){//登录成功
                            sessionStorage.setItem("token", r.data.token);
                            sessionStorage.setItem("roleCode", r.data.roleCode);
                            parent.location.href ='index.html';
                        }else{
                            vm.error = true;
                            vm.errorMsg = r.info;
                         
                        }
                    },
                    error:function(){
                    console.log(r.code);
                    }
                });

            },
            register:function () {
                //注册
                parent.location.href ='/register.html';
            }
        },
        mounted:function () {
            //增加回车登录功能
            document.onkeydown = function(e){
                if(!e) e = window.event;//火狐中是 window.event
                if((e.keyCode || e.which) == 13){
                    vm.login();
                }
            }

        }
    });
</script>
</body>
</html>
